#include<bits/stdc++.h>
using namespace std;

int a[100005], b[100005];

int main()
{
	int m, n;
	cin>>m>>n;
	
	memset(a, 0x3f, sizeof a);
	
	for(int i = 1;i <= m;i++)
		cin>>a[i];
	for(int j = 1;j <= n;j++)
		cin>>b[j];
	
	sort(a+1, a+m+1);
	int ans = 0;
	
	for(int i = 1;i <= n;i++)
	{
		int idx = lower_bound(a+1, a+m+1, b[i])-a;
		ans += min(abs(a[idx]-b[i]), abs(a[idx-1]-b[i]));
	}
	cout<<ans;
	return 0;
}

